home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / utilit~1 / futilsrc.zoo / fileutil / lib / posixtm.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-10-20  |  22.7 KB  |  842 lines

  1.  
  2. /*  A Bison parser, made from posixtm.y  */
  3.  
  4. #define    digit    258
  5.  
  6. #line 19 "posixtm.y"
  7.  
  8. #ifdef __GNUC__
  9. #define alloca __builtin_alloca
  10. #else
  11. #ifdef sparc
  12. #include <alloca.h>
  13. #else
  14. #ifdef _AIX
  15.  #pragma alloca
  16. #else
  17. char *alloca ();
  18. #endif
  19. #endif
  20. #endif
  21. #line 37 "posixtm.y"
  22.  
  23. #include <stdio.h>
  24. #include <sys/types.h>
  25. #include <time.h>
  26.  
  27. #define YYDEBUG 1
  28.  
  29. static char *curpos;
  30.  
  31. static struct tm t;
  32.  
  33. time_t mktime ();
  34.  
  35. static int zzlex ();
  36. #define zzparse posixtime_zzparse
  37. static int zzerror ();
  38.  
  39. #ifndef YYLTYPE
  40. typedef
  41.   struct zzltype
  42.     {
  43.       int timestamp;
  44.       int first_line;
  45.       int first_column;
  46.       int last_line;
  47.       int last_column;
  48.       char *text;
  49.    }
  50.   zzltype;
  51.  
  52. #define YYLTYPE zzltype
  53. #endif
  54.  
  55. #define    YYACCEPT    return(0)
  56. #define    YYABORT    return(1)
  57. #define    YYERROR    goto zzerrlab
  58. #ifndef YYSTYPE
  59. #define YYSTYPE int
  60. #endif
  61. #include <stdio.h>
  62.  
  63. #ifndef __STDC__
  64. #define const
  65. #endif
  66.  
  67.  
  68.  
  69. #define    YYFINAL        15
  70. #define    YYFLAG        -32768
  71. #define    YYNTBASE    5
  72.  
  73. #define YYTRANSLATE(x) ((unsigned)(x) <= 258 ? zztranslate[x] : 9)
  74.  
  75. static const char zztranslate[] = {     0,
  76.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  77.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  78.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  79.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  80.      2,     2,     2,     2,     2,     4,     2,     2,     2,     2,
  81.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  82.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  83.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  84.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  85.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  86.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  87.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  88.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  89.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  90.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  91.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  92.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  93.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  94.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  95.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  96.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  97.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  98.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  99.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  100.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  101.      2,     2,     2,     2,     2,     1,     2,     3
  102. };
  103.  
  104. static const short zzrline[] = {     0,
  105.     56,    85,    92,    99,   110,   113,   122
  106. };
  107.  
  108. static const char * const zztname[] = {     0,
  109. "error","$illegal.","digit","'.'","date"
  110. };
  111.  
  112. static const short zzr1[] = {     0,
  113.      5,     6,     6,     6,     7,     7,     8
  114. };
  115.  
  116. static const short zzr2[] = {     0,
  117.      6,     1,     2,     0,     0,     2,     2
  118. };
  119.  
  120. static const short zzdefact[] = {     0,
  121.      0,     0,     7,     0,     0,     4,     5,     2,     0,     1,
  122.      3,     6,     0,     0,     0
  123. };
  124.  
  125. static const short zzdefgoto[] = {    13,
  126.      7,    10,     2
  127. };
  128.  
  129. static const short zzpact[] = {     2,
  130.      5,     2,-32768,     2,     2,     2,    -3,     2,     2,-32768,
  131. -32768,-32768,     9,    10,-32768
  132. };
  133.  
  134. static const short zzpgoto[] = {-32768,
  135. -32768,-32768,    -2
  136. };
  137.  
  138.  
  139. #define    YYLAST        10
  140.  
  141.  
  142. static const short zztable[] = {     4,
  143.      9,     5,     6,     8,     1,    11,    12,     3,    14,    15
  144. };
  145.  
  146. static const short zzcheck[] = {     2,
  147.      4,     4,     5,     6,     3,     8,     9,     3,     0,     0
  148. };
  149. #define YYPURE 1
  150.  
  151. #include <memory.h>
  152. #line 3 "bison.simple"
  153.  
  154. /* Skeleton output parser for bison,
  155.    copyright (C) 1984 Bob Corbett and Richard Stallman
  156.  
  157.                NO WARRANTY
  158.  
  159.   BECAUSE THIS PROGRAM IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY
  160. NO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW.  EXCEPT
  161. WHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC,
  162. RICHARD M. STALLMAN AND/OR OTHER PARTIES PROVIDE THIS PROGRAM "AS IS"
  163. WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
  164. BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  165. FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY
  166. AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE PROGRAM PROVE
  167. DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
  168. CORRECTION.
  169.  
  170.  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL RICHARD M.
  171. STALLMAN, THE FREE SOFTWARE FOUNDATION, INC., AND/OR ANY OTHER PARTY
  172. WHO MAY MODIFY AND REDISTRIBUTE THIS PROGRAM AS PERMITTED BELOW, BE
  173. LIABLE TO YOU FOR DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR
  174. OTHER SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
  175. USE OR INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR
  176. DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR
  177. A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) THIS
  178. PROGRAM, EVEN IF YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH
  179. DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY.
  180.  
  181.         GENERAL PUBLIC LICENSE TO COPY
  182.  
  183.   1. You may copy and distribute verbatim copies of this source file
  184. as you receive it, in any medium, provided that you conspicuously and
  185. appropriately publish on each copy a valid copyright notice "Copyright
  186. (C) 1985 Free Software Foundation, Inc."; and include following the
  187. copyright notice a verbatim copy of the above disclaimer of warranty
  188. and of this License.  You may charge a distribution fee for the
  189. physical act of transferring a copy.
  190.  
  191.   2. You may modify your copy or copies of this source file or
  192. any portion of it, and copy and distribute such modifications under
  193. the terms of Paragraph 1 above, provided that you also do the following:
  194.  
  195.     a) cause the modified files to carry prominent notices stating
  196.     that you changed the files and the date of any change; and
  197.  
  198.     b) cause the whole of any work that you distribute or publish,
  199.     that in whole or in part contains or is a derivative of this
  200.     program or any part thereof, to be licensed at no charge to all
  201.     third parties on terms identical to those contained in this
  202.     License Agreement (except that you may choose to grant more extensive
  203.     warranty protection to some or all third parties, at your option).
  204.  
  205.     c) You may charge a distribution fee for the physical act of
  206.     transferring a copy, and you may at your option offer warranty
  207.     protection in exchange for a fee.
  208.  
  209. Mere aggregation of another unrelated program with this program (or its
  210. derivative) on a volume of a storage or distribution medium does not bring
  211. the other program under the scope of these terms.
  212.  
  213.   3. You may copy and distribute this program (or a portion or derivative
  214. of it, under Paragraph 2) in object code or executable form under the terms
  215. of Paragraphs 1 and 2 above provided that you also do one of the following:
  216.  
  217.     a) accompany it with the complete corresponding machine-readable
  218.     source code, which must be distributed under the terms of
  219.     Paragraphs 1 and 2 above; or,
  220.  
  221.     b) accompany it with a written offer, valid for at least three
  222.     years, to give any third party free (except for a nominal
  223.     shipping charge) a complete machine-readable copy of the
  224.     corresponding source code, to be distributed under the terms of
  225.     Paragraphs 1 and 2 above; or,
  226.  
  227.     c) accompany it with the information you received as to where the
  228.     corresponding source code may be obtained.  (This alternative is
  229.     allowed only for noncommercial distribution and only if you
  230.     received the program in object code or executable form alone.)
  231.  
  232. For an executable file, complete source code means all the source code for
  233. all modules it contains; but, as a special exception, it need not include
  234. source code for modules which are standard libraries that accompany the
  235. operating system on which the executable file runs.
  236.  
  237.   4. You may not copy, sublicense, distribute or transfer this program
  238. except as expressly provided under this License Agreement.  Any attempt
  239. otherwise to copy, sublicense, distribute or transfer this program is void and
  240. your rights to use the program under this License agreement shall be
  241. automatically terminated.  However, parties who have received computer
  242. software programs from you with this License Agreement will not have
  243. their licenses terminated so long as such parties remain in full compliance.
  244.  
  245.   5. If you wish to incorporate parts of this program into other free
  246. programs whose distribution conditions are different, write to the Free
  247. Software Foundation at 675 Mass Ave, Cambridge, MA 02139.  We have not yet
  248. worked out a simple rule that can be stated here, but we will often permit
  249. this.  We will be guided by the two goals of preserving the free status of
  250. all derivatives of our free software and of promoting the sharing and reuse of
  251. software.
  252.  
  253.  
  254. In other words, you are welcome to use, share and improve this program.
  255. You are forbidden to forbid anyone else to use, share and improve
  256. what you give them.   Help stamp out software-hoarding!  */
  257.  
  258. /* This is the parser code that is written into each bison parser
  259.   when the %semantic_parser declaration is not specified in the grammar.
  260.   It was written by Richard Stallman by simplifying the hairy parser
  261.   used when %semantic_parser is specified.  */
  262.  
  263. /* Note: there must be only one dollar sign in this file.
  264.    It is replaced by the list of actions, each action
  265.    as one case of the switch.  */
  266.  
  267. #define zzerrok        (zzerrstatus = 0)
  268. #define zzclearin    (zzchar = YYEMPTY)
  269. #define YYEMPTY        -2
  270. #define YYEOF        0
  271. #define YYFAIL        goto zzerrlab;
  272.  
  273. #define YYTERROR    1
  274.  
  275. #ifndef YYIMPURE
  276. #define YYLEX        zzlex()
  277. #endif
  278.  
  279. #ifndef YYPURE
  280. #define YYLEX        zzlex(&zzlval, &zzlloc)
  281. #endif
  282.  
  283. /* If nonreentrant, generate the variables here */
  284.  
  285. #ifndef YYIMPURE
  286.  
  287. int    zzchar;            /*  the lookahead symbol        */
  288. YYSTYPE    zzlval;            /*  the semantic value of the        */
  289.                 /*  lookahead symbol            */
  290.  
  291. YYLTYPE zzlloc;            /*  location data for the lookahead    */
  292.                 /*  symbol                */
  293.  
  294. int zznerr;            /*  number of parse errors so far       */
  295.  
  296. #ifdef YYDEBUG
  297. int zzdebug = 0;        /*  nonzero means print parse trace    */
  298. #endif
  299.  
  300. #endif  /* YYIMPURE */
  301.  
  302.  
  303. /*  YYMAXDEPTH indicates the initial size of the parser's stacks    */
  304.  
  305. #ifndef    YYMAXDEPTH
  306. #define YYMAXDEPTH 200
  307. #endif
  308.  
  309. /*  YYMAXLIMIT is the maximum size the stacks can grow to
  310.     (effective only if the built-in stack extension method is used).  */
  311.  
  312. #ifndef YYMAXLIMIT
  313. #define YYMAXLIMIT 10000
  314. #endif
  315.  
  316.  
  317. #line 168 "bison.simple"
  318. int
  319. zzparse()
  320. {
  321.   register int zzstate;
  322.   register int zzn;
  323.   register short *zzssp;
  324.   register YYSTYPE *zzvsp;
  325.   YYLTYPE *zzlsp;
  326.   int zzerrstatus;    /*  number of tokens to shift before error messages enabled */
  327.   int zzchar1;        /*  lookahead token as an internal (translated) token number */
  328.  
  329.   short    zzssa[YYMAXDEPTH];    /*  the state stack            */
  330.   YYSTYPE zzvsa[YYMAXDEPTH];    /*  the semantic value stack        */
  331.   YYLTYPE zzlsa[YYMAXDEPTH];    /*  the location stack            */
  332.  
  333.   short *zzss = zzssa;        /*  refer to the stacks thru separate pointers */
  334.   YYSTYPE *zzvs = zzvsa;    /*  to allow zzoverflow to reallocate them elsewhere */
  335.   YYLTYPE *zzls = zzlsa;
  336.  
  337.   int zzmaxdepth = YYMAXDEPTH;
  338.  
  339. #ifndef YYPURE
  340.   int zzchar;
  341.   YYSTYPE zzlval;
  342.   YYLTYPE zzlloc;
  343. #endif
  344.  
  345. #ifdef YYDEBUG
  346.   extern int zzdebug;
  347. #endif
  348.  
  349.  
  350.   YYSTYPE zzval;        /*  the variable used to return        */
  351.                 /*  semantic values from the action    */
  352.                 /*  routines                */
  353.  
  354.   int zzlen;
  355.  
  356. #ifdef YYDEBUG
  357.   if (zzdebug)
  358.     fprintf(stderr, "Starting parse\n");
  359. #endif
  360.  
  361.   zzstate = 0;
  362.   zzerrstatus = 0;
  363.   zznerr = 0;
  364.   zzchar = YYEMPTY;        /* Cause a token to be read.  */
  365.  
  366.   /* Initialize stack pointers.
  367.      Waste one element of value and location stack
  368.      so that they stay on the same level as the state stack.  */
  369.  
  370.   zzssp = zzss - 1;
  371.   zzvsp = zzvs;
  372.   zzlsp = zzls;
  373.  
  374. /* Push a new state, which is found in  zzstate  .  */
  375. /* In all cases, when you get here, the value and location stacks
  376.    have just been pushed. so pushing a state here evens the stacks.  */
  377. zznewstate:
  378.  
  379.   *++zzssp = zzstate;
  380.  
  381.   if (zzssp >= zzss + zzmaxdepth - 1)
  382.     {
  383.       /* Give user a chance to reallocate the stack */
  384.       /* Use copies of these so that the &'s don't force the real ones into memory. */
  385.       YYSTYPE *zzvs1 = zzvs;
  386.       YYLTYPE *zzls1 = zzls;
  387.       short *zzss1 = zzss;
  388.  
  389.       /* Get the current used size of the three stacks, in elements.  */
  390.       int size = zzssp - zzss + 1;
  391.  
  392. #ifdef zzoverflow
  393.       /* Each stack pointer address is followed by the size of
  394.      the data in use in that stack, in bytes.  */
  395.       zzoverflow("parser stack overflow",
  396.          &zzss1, size * sizeof (*zzssp),
  397.          &zzvs1, size * sizeof (*zzvsp),
  398.          &zzls1, size * sizeof (*zzlsp),
  399.          &zzmaxdepth);
  400.  
  401.       zzss = zzss1; zzvs = zzvs1; zzls = zzls1;
  402. #else /* no zzoverflow */
  403.       /* Extend the stack our own way.  */
  404.       if (zzmaxdepth >= YYMAXLIMIT)
  405.     zzerror("parser stack overflow");
  406.       zzmaxdepth *= 2;
  407.       if (zzmaxdepth > YYMAXLIMIT)
  408.     zzmaxdepth = YYMAXLIMIT;
  409.       zzss = (short *) alloca (zzmaxdepth * sizeof (*zzssp));
  410.       bcopy ((char *)zzss1, (char *)zzss, size * sizeof (*zzssp));
  411.       zzvs = (YYSTYPE *) alloca (zzmaxdepth * sizeof (*zzvsp));
  412.       bcopy ((char *)zzvs1, (char *)zzvs, size * sizeof (*zzvsp));
  413. #ifdef YYLSP_NEEDED
  414.       zzls = (YYLTYPE *) alloca (zzmaxdepth * sizeof (*zzlsp));
  415.       bcopy ((char *)zzls1, (char *)zzls, size * sizeof (*zzlsp));
  416. #endif
  417. #endif /* no zzoverflow */
  418.  
  419.       zzssp = zzss + size - 1;
  420.       zzvsp = zzvs + size - 1;
  421. #ifdef YYLSP_NEEDED
  422.       zzlsp = zzls + size - 1;
  423. #endif
  424.  
  425. #ifdef YYDEBUG
  426.       if (zzdebug)
  427.     fprintf(stderr, "Stack size increased to %d\n", zzmaxdepth);
  428. #endif
  429.  
  430.       if (zzssp >= zzss + zzmaxdepth - 1)
  431.     YYABORT;
  432.     }
  433.  
  434. #ifdef YYDEBUG
  435.   if (zzdebug)
  436.     fprintf(stderr, "Entering state %d\n", zzstate);
  437. #endif
  438.  
  439. /* Do appropriate processing given the current state.  */
  440. /* Read a lookahead token if we need one and don't already have one.  */
  441. zzresume:
  442.  
  443.   /* First try to decide what to do without reference to lookahead token.  */
  444.  
  445.   zzn = zzpact[zzstate];
  446.   if (zzn == YYFLAG)
  447.     goto zzdefault;
  448.  
  449.   /* Not known => get a lookahead token if don't already have one.  */
  450.  
  451.   /* zzchar is either YYEMPTY or YYEOF
  452.      or a valid token in external form.  */
  453.  
  454.   if (zzchar == YYEMPTY)
  455.     {
  456. #ifdef YYDEBUG
  457.       if (zzdebug)
  458.     fprintf(stderr, "Reading a token: ");
  459. #endif
  460.       zzchar = YYLEX;
  461.     }
  462.  
  463.   /* Convert token to internal form (in zzchar1) for indexing tables with */
  464.  
  465.   if (zzchar <= 0)        /* This means end of input. */
  466.     {
  467.       zzchar1 = 0;
  468.       zzchar = YYEOF;        /* Don't call YYLEX any more */
  469.  
  470. #ifdef YYDEBUG
  471.       if (zzdebug)
  472.     fprintf(stderr, "Now at end of input.\n");
  473. #endif
  474.     }
  475.   else
  476.     {
  477.       zzchar1 = YYTRANSLATE(zzchar);
  478.  
  479. #ifdef YYDEBUG
  480.       if (zzdebug)
  481.     fprintf(stderr, "Next token is %d (%s)\n", zzchar, zztname[zzchar1]);
  482. #endif
  483.     }
  484.  
  485.   zzn += zzchar1;
  486.   if (zzn < 0 || zzn > YYLAST || zzcheck[zzn] != zzchar1)
  487.     goto zzdefault;
  488.  
  489.   zzn = zztable[zzn];
  490.  
  491.   /* zzn is what to do for this token type in this state.
  492.      Negative => reduce, -zzn is rule number.
  493.      Positive => shift, zzn is new state.
  494.        New state is final state => don't bother to shift,
  495.        just return success.
  496.      0, or most negative number => error.  */
  497.  
  498.   if (zzn < 0)
  499.     {
  500.       if (zzn == YYFLAG)
  501.     goto zzerrlab;
  502.       zzn = -zzn;
  503.       goto zzreduce;
  504.     }
  505.   else if (zzn == 0)
  506.     goto zzerrlab;
  507.  
  508.   if (zzn == YYFINAL)
  509.     YYACCEPT;
  510.  
  511.   /* Shift the lookahead token.  */
  512.  
  513. #ifdef YYDEBUG
  514.   if (zzdebug)
  515.     fprintf(stderr, "Shifting token %d (%s), ", zzchar, zztname[zzchar1]);
  516. #endif
  517.  
  518.   /* Discard the token being shifted unless it is eof.  */
  519.   if (zzchar != YYEOF)
  520.     zzchar = YYEMPTY;
  521.  
  522.   *++zzvsp = zzlval;
  523. #ifdef YYLSP_NEEDED
  524.   *++zzlsp = zzlloc;
  525. #endif
  526.  
  527.   /* count tokens shifted since error; after three, turn off error status.  */
  528.   if (zzerrstatus) zzerrstatus--;
  529.  
  530.   zzstate = zzn;
  531.   goto zznewstate;
  532.  
  533. /* Do the default action for the current state.  */
  534. zzdefault:
  535.  
  536.   zzn = zzdefact[zzstate];
  537.   if (zzn == 0)
  538.     goto zzerrlab;
  539.  
  540. /* Do a reduction.  zzn is the number of a rule to reduce with.  */
  541. zzreduce:
  542.   zzlen = zzr2[zzn];
  543.   zzval = zzvsp[1-zzlen]; /* implement default value of the action */
  544.  
  545. #ifdef YYDEBUG
  546.   if (zzdebug)
  547.     {
  548.       if (zzlen == 1)
  549.     fprintf (stderr, "Reducing 1 value via line %d, ",
  550.          zzrline[zzn]);
  551.       else
  552.     fprintf (stderr, "Reducing %d values via line %d, ",
  553.          zzlen, zzrline[zzn]);
  554.     }
  555. #endif
  556.  
  557.  
  558.   switch (zzn) {
  559.  
  560. case 1:
  561. #line 62 "posixtm.y"
  562. {
  563.              if (zzvsp[-5] >= 1 && zzvsp[-5] <= 12)
  564.            t.tm_mon = zzvsp[-5] - 1;
  565.          else {
  566.            YYABORT;
  567.          }
  568.          if (zzvsp[-4] >= 1 && zzvsp[-4] <= 31)
  569.            t.tm_mday = zzvsp[-4];
  570.          else {
  571.            YYABORT;
  572.          }
  573.          if (zzvsp[-3] >= 0 && zzvsp[-3] <= 23)
  574.            t.tm_hour = zzvsp[-3];
  575.          else {
  576.            YYABORT;
  577.          }
  578.          if (zzvsp[-2] >= 0 && zzvsp[-2] <= 59)
  579.            t.tm_min = zzvsp[-2];
  580.          else {
  581.            YYABORT;
  582.          }
  583.            ;
  584.     break;}
  585. case 2:
  586. #line 85 "posixtm.y"
  587. {
  588.                    t.tm_year = zzvsp[0];
  589.            /* Deduce the century based on the year.
  590.               See POSIX.2 section 4.63.3.  */
  591.            if (zzvsp[0] <= 68)
  592.              t.tm_year += 100;
  593.          ;
  594.     break;}
  595. case 3:
  596. #line 92 "posixtm.y"
  597. {
  598.                             t.tm_year = zzvsp[-1] * 100 + zzvsp[0];
  599.                 if (t.tm_year < 1900) {
  600.                   YYABORT;
  601.                 } else
  602.                   t.tm_year -= 1900;
  603.               ;
  604.     break;}
  605. case 4:
  606. #line 99 "posixtm.y"
  607. {
  608.                     time_t now;
  609.             struct tm *tmp;
  610.  
  611.                     /* Use current year.  */
  612.                     time (&now);
  613.             tmp = localtime (&now);
  614.             t.tm_year = tmp->tm_year;
  615.           ;
  616.     break;}
  617. case 5:
  618. #line 110 "posixtm.y"
  619. {
  620.                         t.tm_sec = 0;
  621.               ;
  622.     break;}
  623. case 6:
  624. #line 113 "posixtm.y"
  625. {
  626.                       if (zzvsp[0] >= 0 && zzvsp[0] <= 61)
  627.                 t.tm_sec = zzvsp[0];
  628.               else {
  629.                 YYABORT;
  630.               }
  631.             ;
  632.     break;}
  633. case 7:
  634. #line 122 "posixtm.y"
  635. {
  636.                           zzval = zzvsp[-1] * 10 + zzvsp[0];
  637.             ;
  638.     break;}
  639. }
  640.    /* the action file gets copied in in place of this dollarsign */
  641. #line 409 "bison.simple"
  642.  
  643.   zzvsp -= zzlen;
  644.   zzssp -= zzlen;
  645. #ifdef YYLSP_NEEDED
  646.   zzlsp -= zzlen;
  647. #endif
  648.  
  649. #ifdef YYDEBUG
  650.   if (zzdebug)
  651.     {
  652.       short *ssp1 = zzss - 1;
  653.       fprintf (stderr, "state stack now");
  654.       while (ssp1 != zzssp)
  655.     fprintf (stderr, " %d", *++ssp1);
  656.       fprintf (stderr, "\n");
  657.     }
  658. #endif
  659.  
  660.   *++zzvsp = zzval;
  661.  
  662. #ifdef YYLSP_NEEDED
  663.   zzlsp++;
  664.   if (zzlen == 0)
  665.     {
  666.       zzlsp->first_line = zzlloc.first_line;
  667.       zzlsp->first_column = zzlloc.first_column;
  668.       zzlsp->last_line = (zzlsp-1)->last_line;
  669.       zzlsp->last_column = (zzlsp-1)->last_column;
  670.       zzlsp->text = 0;
  671.     }
  672.   else
  673.     {
  674.       zzlsp->last_line = (zzlsp+zzlen-1)->last_line;
  675.       zzlsp->last_column = (zzlsp+zzlen-1)->last_column;
  676.     }
  677. #endif
  678.  
  679.   /* Now "shift" the result of the reduction.
  680.      Determine what state that goes to,
  681.      based on the state we popped back to
  682.      and the rule number reduced by.  */
  683.  
  684.   zzn = zzr1[zzn];
  685.  
  686.   zzstate = zzpgoto[zzn - YYNTBASE] + *zzssp;
  687.   if (zzstate >= 0 && zzstate <= YYLAST && zzcheck[zzstate] == *zzssp)
  688.     zzstate = zztable[zzstate];
  689.   else
  690.     zzstate = zzdefgoto[zzn - YYNTBASE];
  691.  
  692.   goto zznewstate;
  693.  
  694. zzerrlab:   /* here on detecting error */
  695.  
  696.   if (! zzerrstatus)
  697.     /* If not already recovering from an error, report this error.  */
  698.     {
  699.       ++zznerr;
  700.       zzerror("parse error");
  701.     }
  702.  
  703.   if (zzerrstatus == 3)
  704.     {
  705.       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
  706.  
  707.       /* return failure if at end of input */
  708.       if (zzchar == YYEOF)
  709.     YYABORT;
  710.  
  711. #ifdef YYDEBUG
  712.       if (zzdebug)
  713.     fprintf(stderr, "Discarding token %d (%s).\n", zzchar, zztname[zzchar1]);
  714. #endif
  715.  
  716.       zzchar = YYEMPTY;
  717.     }
  718.  
  719.   /* Else will try to reuse lookahead token
  720.      after shifting the error token.  */
  721.  
  722.   zzerrstatus = 3;        /* Each real token shifted decrements this */
  723.  
  724.   goto zzerrhandle;
  725.  
  726. zzerrdefault:  /* current state does not do anything special for the error token. */
  727.  
  728. #if 0
  729.   /* This is wrong; only states that explicitly want error tokens
  730.      should shift them.  */
  731.   zzn = zzdefact[zzstate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
  732.   if (zzn) goto zzdefault;
  733. #endif
  734.  
  735. zzerrpop:   /* pop the current state because it cannot handle the error token */
  736.  
  737.   if (zzssp == zzss) YYABORT;
  738.   zzvsp--;
  739.   zzstate = *--zzssp;
  740. #ifdef YYLSP_NEEDED
  741.   zzlsp--;
  742. #endif
  743.  
  744. #ifdef YYDEBUG
  745.   if (zzdebug)
  746.     {
  747.       short *ssp1 = zzss - 1;
  748.       fprintf (stderr, "Error: state stack now");
  749.       while (ssp1 != zzssp)
  750.     fprintf (stderr, " %d", *++ssp1);
  751.       fprintf (stderr, "\n");
  752.     }
  753. #endif
  754.  
  755. zzerrhandle:
  756.  
  757.   zzn = zzpact[zzstate];
  758.   if (zzn == YYFLAG)
  759.     goto zzerrdefault;
  760.  
  761.   zzn += YYTERROR;
  762.   if (zzn < 0 || zzn > YYLAST || zzcheck[zzn] != YYTERROR)
  763.     goto zzerrdefault;
  764.  
  765.   zzn = zztable[zzn];
  766.   if (zzn < 0)
  767.     {
  768.       if (zzn == YYFLAG)
  769.     goto zzerrpop;
  770.       zzn = -zzn;
  771.       goto zzreduce;
  772.     }
  773.   else if (zzn == 0)
  774.     goto zzerrpop;
  775.  
  776.   if (zzn == YYFINAL)
  777.     YYACCEPT;
  778.  
  779. #ifdef YYDEBUG
  780.   if (zzdebug)
  781.     fprintf(stderr, "Shifting error token, ");
  782. #endif
  783.  
  784.   *++zzvsp = zzlval;
  785. #ifdef YYLSP_NEEDED
  786.   *++zzlsp = zzlloc;
  787. #endif
  788.  
  789.   zzstate = zzn;
  790.   goto zznewstate;
  791. }
  792. #line 126 "posixtm.y"
  793.  
  794. static int
  795. zzlex ()
  796. {
  797.   char ch = *curpos++;
  798.  
  799.   if (ch >= '0' && ch <= '9')
  800.     {
  801.       zzlval = ch - '0';
  802.       return digit;
  803.     }
  804.   else if (ch == '.' || ch == '\0')
  805.     return ch;
  806.   else
  807.     /* Cause an error.  */
  808.     return '?';
  809. }
  810.  
  811. static int
  812. zzerror ()
  813. {
  814.   return 0;
  815. }
  816.  
  817. /* Parse a POSIX-style date and return it, or (time_t)-1 for an error.  */
  818.  
  819. time_t
  820. posixtime (s)
  821.      char *s;
  822. {
  823.   curpos = s;
  824.   /* Let mktime() decide whether it is daylight savings time.  */
  825.   t.tm_isdst = -1;
  826.   if (zzparse ())
  827.     return (time_t)-1;
  828.   else
  829.     return mktime (&t);
  830. }
  831.  
  832. /* Parse a POSIX-style date and return it, or NULL for an error.  */
  833.  
  834. struct tm *
  835. posixtm (s)
  836.      char *s;
  837. {
  838.   if (posixtime (s) == -1)
  839.     return NULL;
  840.   return &t;
  841. }
  842.